package com.svs.framework.web;

import com.alibaba.fastjson.JSON;
import com.svs.framework.shiro.util.ShiroUtils;
import com.svs.framework.shiro.util.SysConstants;
import com.svs.system.domain.SysUser;

/**
 * web层通用数据处理
 * 
 * @author dujianqiao
 */
public class BackendController extends BaseController {
	
	public static String gov_user_type = "G" ;
	public static String enterprise_user_type = "E" ;
	public static String sys_user_type = "S" ;

	public SysUser getSysUser() {
		String obj = JSON.toJSONString(ShiroUtils.getSession().getAttribute(SysConstants.USER_SESSION));
		return JSON.parseObject(obj, SysUser.class);
	}

	public void setSysUser(SysUser user) {
		ShiroUtils.setSysUser(user);
	}

	public Long getUserId() {
		return getSysUser().getUserId();
	}

	public String getLoginName() {
		return getSysUser().getLoginName();
	}
	
	public boolean isGovUser() {
		String userType = getSysUser().getUserType() ;
		return gov_user_type.equals(userType) ;
	}
	
	public boolean isEnterpriseUser() {
		String userType = getSysUser().getUserType() ;
		return enterprise_user_type.equals(userType) ;
	}
	
	public boolean isSysUser() {
		String userType = getSysUser().getUserType() ;
		return sys_user_type.equals(userType) ;
	}
}
